package reflect;

import java.io.File;

public class Test2 {
    public static void main(String[] args) throws Exception{
        File dir = new File(
                Test2.class.getResource(".").toURI()
        );

        String packName = Test2.class.getPackage().getName();
        File[] subs = dir.listFiles(f -> f.getName().endsWith(".class"));



        for (File sub : subs) {

            String fileName = sub.getName();

            String className = fileName.substring(0, fileName.indexOf("."));

            Class<?> cls = Class.forName(packName + "." + className);
            Object obj = cls.newInstance();
            System.out.println(obj);

        }

        String[] list = dir.list();
        for (String s : list) {
            System.out.println(s);
            String[] split = s.split("\\.");

            Class<?> cls = Class.forName(packName+ "."+ split[0]);
            Object o = cls.newInstance();
            System.out.println(o);

        }



    }
}
